//
// Created by webturing on 2024/1/1.
//

#include<bits/stdc++.h>

using namespace std;
int g[100][100];
int n, m; //n点的个数 m边的个数
int book[100];
int tot = 0;

void dfs(int k) {
    if (tot == n)return;
    cout << k << " ";
    book[k] = 1;
    ++tot;
    for (int i = 1; i <= n; i++) {
        if (book[i] == 0 && g[k][i] == 1) {
            dfs(i);

        }
    }
}

int main() {
    cin >> n;
    for (int x = 0; x < n; x++)
        for (int y = 0; y < n; y++) {
            cin >> g[x][y];
            m += g[x][y];
        }
    fill(book, book + n, 0);
    dfs(0);


    return 0;
}